package com.qing.apple.filter.demo01;

import com.qing.apple.filter.bean.Apple;

import java.util.ArrayList;
import java.util.List;

/**
 * 筛选仓库苹果
 */
public class AppleService {


	/**
	 * 获取所有绿色的苹果
	 * @param apples
	 * @return
	 */
	public static List<Apple> filterGreenColor(List<Apple> apples){
		List<Apple> result=new ArrayList<>();
		for (Apple apple : apples) {
			if("green".equals(apple)){
				result.add(apple);
			}
		}
		return  result;
	}

	/**
	 * 获取所有重量>150g的苹果
	 * @param apples
	 * @return
	 */
	public static List<Apple> filtersHeavyApple(List<Apple> apples){
		List<Apple> result=new ArrayList<>();
		for (Apple apple : apples) {
			if(apple.getWeight()>150){
				result.add(apple);
			}
		}
		return  result;
	}

}
